package com.funtonow.jqdk.base;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.content.Context;

import com.funtonow.jqdk.bean.LoanInfoBean;
import com.funtonow.jqdk.bean.TencentSecretBean;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import com.umeng.analytics.MobclickAgent;
import com.umeng.commonsdk.UMConfigure;
import com.xinyan.bigdata.XinYanSDK;
import com.yilan.sdk.ui.YLUIInit;

import me.jessyan.autosize.AutoSizeConfig;
import me.jessyan.autosize.onAdaptListener;

public class SqjAppliaction extends Application {

    @SuppressLint("StaticFieldLeak")
    private static Context context;

    public static TencentSecretBean tencentSecretBean = null;

    // 贷款临时数据
    public static LoanInfoBean loanInfoBean = null;

    private boolean isLog = false;

    public static Context getContext() {
        return context;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        context = getApplicationContext();

        AutoSizeConfig.getInstance()

                //是否让框架支持自定义 Fragment 的适配参数, 由于这个需求是比较少见的, 所以须要使用者手动开启
                //如果没有这个需求建议不开启
                .setCustomFragment(true)

                //是否屏蔽系统字体大小对 AndroidAutoSize 的影响, 如果为 true, App 内的字体的大小将不会跟随系统设置中字体大小的改变
                //如果为 false, 则会跟随系统设置中字体大小的改变, 默认为 false
                .setExcludeFontScale(true)

                //屏幕适配监听器
                .setOnAdaptListener(new onAdaptListener() {
                    @Override
                    public void onAdaptBefore(Object target, Activity activity) {
                        //使用以下代码, 可支持 Android 的分屏或缩放模式, 但前提是在分屏或缩放模式下当用户改变您 App 的窗口大小时
                        //系统会重绘当前的页面, 经测试在某些机型, 某些情况下系统不会重绘当前页面, ScreenUtils.getScreenSize(activity) 的参数一定要不要传 Application!!!
//                        AutoSizeConfig.getInstance().setScreenWidth(ScreenUtils.getScreenSize(activity)[0]);
//                        AutoSizeConfig.getInstance().setScreenHeight(ScreenUtils.getScreenSize(activity)[1]);
                    }

                    @Override
                    public void onAdaptAfter(Object target, Activity activity) {
                    }
                });

        UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, "");
        MobclickAgent.setDebugMode(true);
        MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);

        //初始化
        YLUIInit.getInstance()
                .setApplication(this)
                .setAccessKey("ylxufyf2pyin")
                .setAccessToken("zsv49n0lgz47o6c18f6rr9syf79o3psy")
                .setUid("0")
                .build();
        if (isLog){
            Logger.addLogAdapter(new AndroidLogAdapter());
        }
        XinYanSDK.getInstance().init(this,"8150752075","c139b5868d974a8cad2fd15aa6b9a4df");
//        if (LeakCanary.isInAnalyzerProcess(this)) {//1
//            // This process is dedicated to LeakCanary for heap analysis.
//            // You should not init your app in this process.
//            return;
//        }
//        LeakCanary.install(this);
    }

}
